package com.mz.ozy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.mz.ozy.R;
import com.mz.ozy.bean.HyRecordBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HYRecordAdapter extends RecyclerView.Adapter<HYRecordAdapter.MyViewHolder> {



    private Context mContext;
    List<HyRecordBean.PageBean.PageItemsBean> mBeanList;
    public HYRecordAdapter(Context context,List<HyRecordBean.PageBean.PageItemsBean> mBeanList) {
        this.mContext = context;
        this.mBeanList = mBeanList;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_hy_record, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        HyRecordBean.PageBean.PageItemsBean bean = mBeanList.get(position);
       holder.tvMoney.setText(bean.getAmt());
       holder.tvDepositTime.setText(mContext.getString(R.string.deposit_time,bean.getCreated()));
        holder.tvMaturityTime.setText(mContext.getString(R.string.maturity_time,bean.getCjTime()));
        holder.tvEarned.setText(mContext.getString(R.string.earned,bean.getProfit()));
        int type = bean.getType();
        if(type == 0){
            holder.tvStatus.setText(mContext.getString(R.string.unexpired));
            holder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.c_f63148));
        }else if(type == 1){
            holder.tvStatus.setText(mContext.getString(R.string.be_expired));
            holder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.text_color_333333));

        }

    }

    @Override
    public int getItemCount() {
        return mBeanList.size();
    }


    static class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tvRemark)
        TextView tvRemark;
        @BindView(R.id.tvMoney)
        TextView tvMoney;
        @BindView(R.id.tv_deposit_time)
        TextView tvDepositTime;
        @BindView(R.id.tvEarned)
        TextView tvEarned;
        @BindView(R.id.tv_maturity_time)
        TextView tvMaturityTime;
        @BindView(R.id.tvStatus)
        TextView tvStatus;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
